package com.youhome.result;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

@Data
@ApiModel
@JsonSerialize(include= JsonSerialize.Inclusion.NON_NULL)
public class ListHubList {
    @ApiModelProperty(value = "房源ID")
    private String houseId;

    @ApiModelProperty(value = "地址")
    private String address;

    @ApiModelProperty(value = "价格")
    private Double listPrice;

    @ApiModelProperty(value = "价格")
    private String listingCategory;

    @JsonIgnore
    @ApiModelProperty(value = "市场key")
    private String listingKey;

    @ApiModelProperty(value = "销售状态")
    private String listingStatus;

    @ApiModelProperty(value = "上市日期")
    private Date listingDate;

    @ApiModelProperty(value = "纬度")
    private Double latitude;

    @ApiModelProperty(value = "经度")
    private Double longitude;
    @JsonIgnore
    @ApiModelProperty(value = "房源经记名称")
    private String providerName;
    @JsonIgnore
    @ApiModelProperty(value = "房源经记网址")
    private String providerUrl;
    @JsonIgnore
    @ApiModelProperty(value = "房源经记类别")
    private String providerCategory;

    @ApiModelProperty(value = "卧室数量")
    private Integer bedroomCount;

    @ApiModelProperty(value = "卫浴数量")
    private Integer bathroomCount;

    @JsonIgnore
    @ApiModelProperty(value = "交易类型,租,售")
    private String propertyType;

    @ApiModelProperty(value = "房源类型")
    private String propertySubtype;

    @ApiModelProperty(notes = "图片")
    private String heroImage;

    @ApiModelProperty(notes = "房源面积")
    private Double livingArea;

    @ApiModelProperty(notes = "土地面积")
    private Double lotSize;

    @ApiModelProperty(notes = "建造年代")
    private Integer yearBuilt;

    @JsonIgnore
    @ApiModelProperty(notes = "是否为明星房源")
    private Boolean isStar;
    @JsonIgnore
    @ApiModelProperty(notes = "是否通过审核")
    private Boolean isCheck;
    @JsonIgnore
    @ApiModelProperty(notes = "归属分组")
    private List<String> shareGroupNames;

    @DateTimeFormat(pattern="yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd")
    public Date getListingDate() {
        return listingDate;
    }

    public String getHeroImage() {
        if (!StringUtils.isEmpty(heroImage)) {
            heroImage = "https://youhome.oss-cn-zhangjiakou.aliyuncs.com/" + heroImage;
        }
        return heroImage;
    }
}